package com.library.demo;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.library.db.ConnectDb;

//import com.library.db.ConnectDb;

/**
 * Servlet implementation class Login
 */
public class Login extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public Login() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException {
		// TODO Auto-generated method stub
	}

	/**
	 * @throws IOException
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("uname");
		String password = request.getParameter("pwd");

		ConnectDb cdb = new ConnectDb();
		try {
			response.getWriter().write(cdb.validateLogin(username, password));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		/*
		 * if(username.equals("skakani")) { if(password.equals("123456")) {
		 * response
		 * .getWriter().write("Welcome!"+username+", you are successfully logined"
		 * );
		 * 
		 * } else{ response.getWriter().write(
		 * "Incorrect password, condsider re-typing your password."); } } else{
		 * response.getWriter().write(
		 * "Incorrect username, condsider re-typing your username."); }
		 */

	}

}
